<?php
/**
 * Модель mail
 * 
 * Класс модели
 * @author Anton Zavidov
 * @package myLiveShop
 */

/**
 * Модель mail
 *
 */
class ModelMail extends Model {
	
	const TABLE				= 'mail';
	const F_MAIL_ID  	= 'mail_id';
	const F_USER_ID  	= 'user_id';
	const F_DELETED  	= 'deleted';
	const F_SYSTEM  	= 'system';
	const F_CREATED  	= 'created';
	const F_TITLE  	= 'title';
	const F_DESCRIPTION  	= 'description';
	const F_LANG_ID  	= 'lang_id';
	const F_PARENT_ID  	= 'parent_id';
			
	public function __construct($className=null){
		parent::__construct(__CLASS__);
		$this->name='mail';
		$this->id_field=array(self::F_MAIL_ID);
		$this->fields=array(
		self::TABLE.DOT.self::F_MAIL_ID=> new Field($this,self::F_MAIL_ID,self::TABLE,array(
				'auto'=>true,
				'important'=>true,
				'lenght'=>11)),
		self::TABLE.DOT.self::F_USER_ID=> new Field($this,self::F_USER_ID,self::TABLE,array(
				'lenght'=>11,
				'join_table'=>'user')),
		self::TABLE.DOT.self::F_DELETED=> new Field($this,self::F_DELETED,self::TABLE,array(
				'important'=>true,
				'lenght'=>1,
				'validate_type'=>Validator::VALIDATE_BOOL)),
		self::TABLE.DOT.self::F_SYSTEM=> new Field($this,self::F_SYSTEM,self::TABLE,array(
				'important'=>true,
				'lenght'=>1,
				'validate_type'=>Validator::VALIDATE_BOOL)),
		self::TABLE.DOT.self::F_CREATED=> new Field($this,self::F_CREATED,self::TABLE,array(
				'important'=>true,
				'auto'=>true,
				'type'=>Field::TYPE_DATETIME)),
		self::TABLE.DOT.self::F_TITLE=> new Field($this,self::F_TITLE,self::TABLE,array(
				'lenght'=>255,
				'type'=>Field::TYPE_STRING)),
		self::TABLE.DOT.self::F_DESCRIPTION=> new Field($this,self::F_DESCRIPTION,self::TABLE,array(
				'type'=>Field::TYPE_TEXT)),
		self::TABLE.DOT.self::F_PARENT_ID=> new Field($this,self::F_PARENT_ID,self::TABLE,array(
				'lenght'=>11,
				'join_table'=>'mail')),
		self::TABLE.DOT.self::F_LANG_ID=> new Field($this,self::F_LANG_ID,self::TABLE,array(
				'auto'=>true,
				'lenght'=>2,
				'join_table'=>'lang'))
		);
	}
}
